@echo off
setlocal ENABLEDELAYEDEXPANSION

:: 基础变量值
set GCC_PATH=C:\Users\virens\AppData\Local\Arduino15\packages\esp32\tools\xtensa-esp32s3-elf-gcc\esp-2021r2-patch5-8.4.0\bin
set ELF_PATH=.\build\virens-arduino-gsm.ino.elf

:: 设置临时变量
set STR_INPUT=%1
set STR_TEMP=

:STR_EX_FIND

:: 获取对应的异常信息
for /f "tokens=1,*" %%a in (%STR_INPUT%) do (
    set STR_INPUT="%%b"
    set STR_TEMP=%%a
    
    if "!STR_TEMP:~0,2!"=="0x" (
      %GCC_PATH%\xtensa-esp32s3-elf-addr2line.exe -e %ELF_PATH% %%a
    )

    goto STR_EX_FIND
)